Add test entry for multiple GPX 1.1 links.
authorrobertl <robertl>
Mon, 12 Mar 2007 15:34:57 +0000 (15:34 +0000)
committerrobertl <robertl>
Mon, 12 Mar 2007 15:34:57 +0000 (15:34 +0000)
Try to fix our handling of schemaLoc in GPX 1.1
Make transform-rte and transform-wpt (validated) GPX 1.1 since they came
 from GPX 1.1.

gpx.c
reference/multiple-links.gpx [new file with mode: 0644]
reference/transform-rte.gpx
reference/transform-wpt.gpx
testo

diff --git a/gpx.c b/gpx.c
index 0dfeda32303248d05adb7bdd5c44dfe128145f6b..cee3d927c43742cf11cbd84622b274360f94e5d3 100644 (file)
--- a/gpx.c
+++ b/gpx.c
@@ -69,6 +69,7 @@ static format_specific_data **fs_ptr;
 #define MYNAME "GPX"
 #define MY_CBUF_SZ 4096
 #define DEFAULT_XSI_SCHEMA_LOC "http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"
+#define DEFAULT_XSI_SCHEMA_LOC_11 "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
 #define DEFAULT_XSI_SCHEMA_LOC_FMT "\"http://www.topografix.com/GPX/%c/%c http://www.topografix.com/GPX/%c/%c/gpx.xsd\""
 #ifndef CREATOR_NAME_URL
 #  define CREATOR_NAME_URL "GPSBabel - http://www.gpsbabel.org"
@@ -389,21 +390,32 @@ prescan_tags(void)
 static void
 tag_gpx(const char **attrv)
 {
-       const char **avp = &attrv[0];
-       while (*avp) {
+       const char **avp;
+       for (avp = &attrv[0]; *avp; avp += 2) {
                if (strcmp(avp[0], "version") == 0) {
                        gpx_version = avp[1];
                }
                else if (strcmp(avp[0], "src") == 0) {
                        gpx_creator = avp[1];
                }
+               /*
+                * Our handling of schemaLocation really is weird.
+                * If we see we have a "normal" GPX 1.1 header, on read,
+                * flip our default on write to use that and don't append
+                * it to the rest...
+                */
                else if (strcmp(avp[0], "xsi:schemaLocation") == 0) {
+                       if (0 == strcmp(avp[1], DEFAULT_XSI_SCHEMA_LOC_11)) {
+                               if (0 == strcmp(xsi_schema_loc, DEFAULT_XSI_SCHEMA_LOC))
+                                       xfree(xsi_schema_loc);
+                                       xsi_schema_loc = xstrdup(DEFAULT_XSI_SCHEMA_LOC_11);
+                               continue;
+                       }
                        if (0 == strstr(xsi_schema_loc, avp[1])) {
                            xsi_schema_loc = xstrappend(xsi_schema_loc, " ");
                            xsi_schema_loc = xstrappend(xsi_schema_loc, avp[1]);
                        }
                }
-               avp+=2;
        }
 }
 
@@ -866,7 +878,6 @@ gpx_end(void *data, const XML_Char *xml_el)
                        lt = xstrdup(lrtrim(link_text));
                }
                
-               fprintf(stderr, "Here %s/%s\n", link_url, lt);
                add_url(wpt_tmp, xstrdup(link_url), lt);
                link_text = NULL;
                }
diff --git a/reference/multiple-links.gpx b/reference/multiple-links.gpx
new file mode 100644 (file)
index 0000000..0e347db
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gpx
+ version="1.1"
+creator="GPSBabel - http://www.gpsbabel.org"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xmlns="http://www.topografix.com/GPX/1/1"
+xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+<metadata>
+<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="21.278604576" minlon="-157.810719665" maxlat="21.278604576" maxlon="-157.810719665"/>
+</metadata>
+<wpt lat="21.278604576" lon="-157.810719665">
+<time>2007-03-10T22:41:34Z</time>
+  <name>001</name>
+  <cmt>3348 Martha St</cmt>
+  <desc>3348 Martha St</desc>
+  <link href="www.one.com">
+  <text>one</text>
+  </link>
+  <link href="www.two.com">
+  <text>two dots</text>
+  </link>
+  <link href="www.twoandahalf.com">
+  </link>
+  <link href="www.three.com">
+  <text>three dots</text>
+  </link>
+  <sym>Waypoint</sym>
+  <extensions>
+    <gpxx:WaypointExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.garmin.com/xmlschemas/GpxExtensions/v2 http://www.garmin.com/xmlschemas/GpxExtensions/v2/GpxExtensionsv2.xsd">
+      <gpxx:DisplayMode>SymbolAndDescription</gpxx:DisplayMode>
+    </gpxx:WaypointExtension>
+  </extensions>
+</wpt>
+</gpx>
index c7ba05f7c7a82b9a962c7719d00688212eeb7577..34df3a1d12eb51b3b6061cda4fc0e1273093aa6c 100644 (file)
@@ -1,12 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gpx
- version="1.0"
+ version="1.1"
 creator="GPSBabel - http://www.gpsbabel.org"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xmlns="http://www.topografix.com/GPX/1/0"
-xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+xmlns="http://www.topografix.com/GPX/1/1"
+xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+<metadata>
 <time>1970-01-01T00:00:00Z</time>
 <bounds minlat="42.401051000" minlon="-71.126602000" maxlat="42.468655000" maxlon="-71.102973000"/>
+</metadata>
 <rte>
   <rtept lat="42.438878000" lon="-71.119277000">
     <ele>44.586548</ele>
index f76d4055b3437b7f44ad9de71a863130fa45fdad..a16a39b412a75e86e0f8a36d92c5765e0e277928 100644 (file)
@@ -1,12 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gpx
- version="1.0"
+ version="1.1"
 creator="GPSBabel - http://www.gpsbabel.org"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xmlns="http://www.topografix.com/GPX/1/0"
-xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+xmlns="http://www.topografix.com/GPX/1/1"
+xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+<metadata>
 <time>1970-01-01T00:00:00Z</time>
 <bounds minlat="42.430950000" minlon="-71.122845000" maxlat="42.467110000" maxlon="-71.105116000"/>
+</metadata>
 <wpt lat="42.430950000" lon="-71.107628000">
   <ele>23.469600</ele>
 <time>2001-06-02T00:18:15Z</time>
diff --git a/testo b/testo
index 36fc4502655e2d16be4fcdc9963eed969b86b71f..895269ac43564ef697613a037c73a8d8df8ca697 100755 (executable)
--- a/testo
+++ b/testo
@@ -1157,9 +1157,9 @@ compare ${TMPDIR}/ge-eg.kml ${REFERENCE}/earth-expertgps.kml
 # Transformation filter (transform) tests
 #
 rm -f ${TMPDIR}/transform*
-${PNAME} -i gpx -f ${REFERENCE}/expertgps.gpx -x nuketypes,routes,tracks -x transform,rte=wpt,del=y -o gpx -F ${TMPDIR}/transform-rte.gpx
+${PNAME} -i gpx -f ${REFERENCE}/expertgps.gpx -x nuketypes,routes,tracks -x transform,rte=wpt,del=y -o gpx,gpxver=1.1 -F ${TMPDIR}/transform-rte.gpx
 compare ${TMPDIR}/transform-rte.gpx ${REFERENCE}/transform-rte.gpx
-${PNAME} -i gpx -f ${REFERENCE}/expertgps.gpx -x nuketypes,waypoints,tracks -x transform,wpt=rte,del=y -o gpx -F ${TMPDIR}/transform-wpt.gpx
+${PNAME} -i gpx -f ${REFERENCE}/expertgps.gpx -x nuketypes,waypoints,tracks -x transform,wpt=rte,del=y -o gpx,gpxver=1.1 -F ${TMPDIR}/transform-wpt.gpx
 compare ${TMPDIR}/transform-wpt.gpx ${REFERENCE}/transform-wpt.gpx
 
 #
@@ -1187,4 +1187,11 @@ ${PNAME} -i alantrl -f ${REFERENCE}/alantrl.trl -o alantrl -F ${TMPDIR}/alantrl-
 ${PNAME} -i alantrl -f ${TMPDIR}/alantrl-new.trl -o gpx -F ${TMPDIR}/alantrl-new.gpx
 compare ${TMPDIR}/alantrl-new.gpx ${REFERENCE}/alantrl.gpx
 
+#
+# Test > 1 URL in selected files.
+#
+rm -f ${TMPDIR}/mlink*
+${PNAME} -i gpx -f reference/multiple-links.gpx -o gpx,gpxver=1.1 -F ${TMPDIR}/mlink-1.gpx
+compare ${TMPDIR}/mlink-1.gpx reference/multiple-links.gpx
+
 exit 0